package com.ujs.edu.medicine.dao;

import com.ujs.edu.medicine.dataobject.YunjiayiVerify;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;
@Mapper
public interface YunjiayiVerifyMapper {
    @Select({
            "select *",
            "from yunjiayi_verify",
            "where userID = #{userID,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column="userID", property="userID", jdbcType= JdbcType.INTEGER),
            @Result(column="files", property="files", jdbcType=JdbcType.VARCHAR),
            @Result(column="content", property="content", jdbcType=JdbcType.VARCHAR),
            @Result(column="verifyID", property="verifyID", jdbcType= JdbcType.INTEGER, id=true),
            @Result(column="createtime", property="createtime", jdbcType=JdbcType.DATE)
    })
    List<YunjiayiVerify> selectByuser(@Param("userID") Integer userID);

    @Select({
            "select *",
            "from yunjiayi_verify",
            "where verifyID= #{verifyID,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column="userID", property="userID", jdbcType= JdbcType.INTEGER),
            @Result(column="files", property="files", jdbcType=JdbcType.VARCHAR),
            @Result(column="content", property="content", jdbcType=JdbcType.VARCHAR),
            @Result(column="verifyID", property="verifyID", jdbcType= JdbcType.INTEGER, id=true),
            @Result(column="createtime", property="createtime", jdbcType=JdbcType.DATE)
    })
   YunjiayiVerify selectByPrimaryKey(@Param("verifyID") Integer verifyID);
    @Select({
            "select file",
            "from yunjiayi_verify",
            "where userID = #{userID,jdbcType=INTEGER}"
    })
    List<String> selectfiles(@Param("userID") Integer userID);
    @Insert({
            "insert into yunjiayi_verify (userID,content, file,createtime)",
            "values (#{userID,jdbcType=INTEGER},#{content,jdbcType=VARCHAR}, #{file,jdbcType=VARCHAR},now())"

    })
    int insert(YunjiayiVerify verify);

    @Select("select * from yunjiayi_verify")
    List<YunjiayiVerify> selectAll();


    @Delete({
            "delete from yunjiayi_verify",
            "where verifyID = #{verifyID,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer userId);
}
